#pragma once

#define VTTYPE_I2              "\x02"      // a 'short'
#define VTTYPE_I4              "\x03"      // a 'long'
#define VTTYPE_R4              "\x04"      // a 'float'
#define VTTYPE_R8              "\x05"      // a 'double'
#define VTTYPE_CY              "\x06"      // a 'CY' or 'CY*'
#define VTTYPE_DATE            "\x07"      // a 'DATE'
#define VTTYPE_WBSTR           "\x08"      // an 'LPCOLESTR'
#define VTTYPE_DISPATCH        "\x09"      // an 'IDispatch*'
#define VTTYPE_SCODE           "\x0A"      // an 'SCODE'
#define VTTYPE_BOOL            "\x0B"      // a 'VARIANT_BOOL'
#define VTTYPE_VARIANT         "\x0C"      // a 'const VARIANT&' or 'VARIANT*'
#define VTTYPE_UNKNOWN         "\x0D"      // an 'IUnknown*'
#if defined(_UNICODE)
#define VTTYPE_BSTR            VTTYPE_WBSTR// an 'LPCOLESTR'
#define VT_BSTRT            VT_BSTR
#else
#define VTTYPE_BSTR            "\x0E"  // an 'LPCSTR'
#define VT_BSTRA            14
#define VT_BSTRT            VT_BSTRA
#endif
#define VTTYPE_I1              "\x10"      // a 'signed char'
#define VTTYPE_UI1             "\x11"      // a 'BYTE'
#define VTTYPE_UI2             "\x12"      // a 'WORD'
#define VTTYPE_UI4             "\x13"      // a 'DWORD'
#define VTTYPE_I8              "\x14"      // a 'LONGLONG'
#define VTTYPE_UI8             "\x15"      // a 'ULONGLONG'

// parameter types: by reference VTTYPE
#define VTTYPE_PI2             "\x42"      // a 'short*'
#define VTTYPE_PI4             "\x43"      // a 'long*'
#define VTTYPE_PR4             "\x44"      // a 'float*'
#define VTTYPE_PR8             "\x45"      // a 'double*'
#define VTTYPE_PCY             "\x46"      // a 'CY*'
#define VTTYPE_PDATE           "\x47"      // a 'DATE*'
#define VTTYPE_PBSTR           "\x48"      // a 'BSTR*'
#define VTTYPE_PDISPATCH       "\x49"      // an 'IDispatch**'
#define VTTYPE_PSCODE          "\x4A"      // an 'SCODE*'
#define VTTYPE_PBOOL           "\x4B"      // a 'VARIANT_BOOL*'
#define VTTYPE_PVARIANT        "\x4C"      // a 'VARIANT*'
#define VTTYPE_PUNKNOWN        "\x4D"      // an 'IUnknown**'
#define VTTYPE_PI1             "\x50"      // a 'signed char*'
#define VTTYPE_PUI1            "\x51"      // a 'BYTE*'
#define VTTYPE_PUI2            "\x52"      // a 'WORD*'
#define VTTYPE_PUI4            "\x53"      // a 'DWORD*'
#define VTTYPE_PI8             "\x54"      // a 'LONGLONG*'
#define VTTYPE_PUI8            "\x55"      // a 'ULONGLONG*'

class SimpleInvokeHelper
{
public:
	SimpleInvokeHelper(IDispatch* pDispatch);
	~SimpleInvokeHelper(void);

	HRESULT Invoke(DISPID dwDispID, WORD wFlags, VARTYPE vtRet, void* pvRet, const BYTE* pbParamInfo, ...);

private:
	void GetVarByType(BYTE type, va_list& paramList, VARIANT* pRet);
private:
	IDispatch* m_pDispatch;
};
